/*
 * Copyright (c) 2018. czmc All Rights Reserved.
 * Author: czmc
 * Email: zxc6355533@163.com
 * Encoding: UTF-8
 */

package top.stime21.myneighbours.module.login.model

import io.reactivex.Observable
import top.stime21.myneighbours.api.ApiManager
import top.stime21.myneighbours.base.io_main
import top.stime21.myneighbours.data.dto.BaseResult
import top.stime21.myneighbours.data.dto.NeedDetailsResult
import top.stime21.myneighbours.data.dto.NeedResult
import top.stime21.myneighbours.module.login.NeedContract

/**
 * Author: czmc  Email: @tuwan21.com
 * Version:	1.0  Date:3/3/2018
 */
class NeedModelImpl : NeedContract.Model{
    override fun details(id: Long): Observable<NeedDetailsResult> {
        return ApiManager.ins().dataApi.details(id).io_main()
    }

    override fun finish(id: Long, uid: Long): Observable<BaseResult> {
        return ApiManager.ins().dataApi.finish(id,uid).io_main()
    }

    override fun myneed(uid: Long, type: Int, page: Int, limit: Int): Observable<NeedResult> {
        return ApiManager.ins().dataApi.myneeds(uid,type,page,limit).io_main()
    }

    override fun publish(type: Int, uid: Long, address: String, lat: Double, lon: Double, content: String, title: String): Observable<BaseResult> {
        return ApiManager.ins().dataApi.publish(type, uid, address, lat, lon, content, title).io_main()
    }


    override fun accept(id: Long, uid: Long): Observable<BaseResult> {
        return ApiManager.ins().dataApi.accept(id,uid).io_main()
    }

    override fun cancel(id: Long, uid: Long, type: Int): Observable<BaseResult> {
        return ApiManager.ins().dataApi.cancle(id,uid,type).io_main()
    }

    override fun nearby(lat: Double, lon: Double, limit: Int): Observable<NeedResult> {
        return ApiManager.ins().dataApi.nearby(lat,lon,limit).io_main()
    }

    override fun search(key: String): Observable<NeedResult> {
        return ApiManager.ins().dataApi.search(key).io_main()
    }
}